from didiball.sprites.PassiveSprite import PassiveSprite

class Goalpost(PassiveSprite):

    def __init__( self, posxy, delta, surface):
        dynamics={}
        dynamics['mass']=100000
        dynamics['friction']=1
        dynamics['max_speed']=0
        PassiveSprite.__init__( self, posxy, 0, 0, surface, dynamics)
        self.__delta = delta
        
        self.set_pos_xy((posxy[0]+delta[0]*self.get_width()*0.5,posxy[1]+delta[1]*self.get_height()*0.5))
        
    def get_delta(self):
        return self.__delta
        
    def set_delta(self,delta):
        self.__delta = delta
        
    def collision(self, B, tick_ms):
        posA = self.get_pos_xy()
        delta = self.get_delta()
        posB = B.get_pos_xy()
        
        if (delta[1]==-1 and posB[1]<=posA[1]) or (delta[1]==1 and posB[1]>=posA[1]):
            return False;
            
        PassiveSprite.collision(self, B, tick_ms)
